package org.dtrd.modules.doctor.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import org.dtrd.config.system.Constant.DoctorVerifyState;
import org.dtrd.config.wechat.entity.bean.officialaccount.WechatOfficialAccountUserInfo;
import org.dtrd.modules.doctor.entity.bean.DoctorInfo;
import org.dtrd.modules.doctor.entity.request.UpdateTeamDoctorRequest;

import javax.persistence.Table;
import java.util.Date;


/**
 * <p>
 * 医生表
 * </p>
 *
 * @author QR
 * @since 2021-11-30 15:09:18
 */
@Data
@TableName("dtrd_ent_rd_doctor")
public class DtrdEntRdDoctor {

    @TableId(value = "data_id", type = IdType.AUTO)
    private Integer dataId;

    /**
     * 所属渠道Id
     */
    private Integer channelId;

    /**
     * 手机号码
     */
    private String doctorsMobile;

    /**
     * 唯一标识
     */
    private String doctorsUuid;

    /**
     * 登录密码
     */
    private String doctorsPassword;

    /**
     * 姓名
     */
    private String doctorsName;

    /**
     * 出生日期
     */
    private Date doctorsBirthday;

    /**
     * 性别
     */
    private Integer doctorsSex;

    /**
     * 身份证号码
     */
    private String doctorsIdCard;

    /**
     * 所属省份Id
     */
    private Integer doctorsProvinceId;

    /**
     * 所属城市Id
     */
    private Integer doctorsCityId;

    /**
     * 所属区Id
     */
    private Integer doctorsDistrictId;

    /**
     * 头像图片地址
     */
    private String doctorsImg;

    /**
     * 所属医院Id
     */
    private String doctorsHospitalId;
    private String doctorsHospital;

    /**
     * 所属部门Id
     */
    private String doctorsDepartmentId;
    private String doctorsDepartment;

    /**
     * 职称Id
     */
    private String doctorsLevelId;
    private String doctorsLevel;

    /**
     * '执业证书图片地址'
     */
    private String doctorsCertificate;

    /**
     * 医师资格证图片地址
     */
    private String doctorsWorkPermits;

    /**
     * 职称证书图片地址
     */
    private String doctorsProfessionImg;

    /**
     * 胸牌
     */
    private String doctorsWorkCard;

    /**
     * 科室电话
     */
    private String doctorsDeptTel;

    /**
     * 技能
     */
    private String doctorsSpecialSkill;

    /**
     * 工作经历
     */
    private String doctorsWorkExperience;

    /**
     * 推荐者Id
     */
    private Integer doctorsRecommendId;

    /**
     * 属于平台医生:1-是,0-否
     */
    private Integer doctorsIsdoctor;

    /**
     * 是否认证:0-审核未通过，1-审核通过
     */
    private Integer doctorsIsverify;

    /**
     * 状态:0-解除冻结,1-冻结
     */
    private Integer doctorsStatus;

    /**
     * 是否显示:1-是,0-否
     */
    private Integer doctorsIsShow;

    /**
     * 已推荐
     */
    private Integer doctorsRecommended;

    /**
     * 添加医生团队二维码
     */
    private String qrcodeAddTeam;

    /**
     * 添加患者二维码
     */
    private String qrcodeAddPatient;

    /**
     * 微信二维码原始链接
     */
    @TableField("wx_oa_qrcode_source_url")
    private String wxOaQrcodeSourceUrl;

    /**
     * 使用医院来源
     */
    private Integer doctorsIsCustom;

    /**
     * 医联邀请码
     */
    private String doctorsInvitationCode;

    /**
     * 医生近两周活跃度
     */
    private Integer doctorsLiveness;

    /**
     * 医生星评的平均分
     */
    private Float doctorsScore;

    /**
     * 是否是名医:0-否,1-是
     */
    private Integer doctorsIsFamous;

    /**
     * 来源类型
     */
    private Integer doctorsSourceType;

    /**
     * 是否开通名医问诊  0 未开通 1 开通
     */
    private Integer doctorsIsInquiry;

    /**
     * 医生类型：1-科室主任,2-医生,3-健康管理师/护士
     */
    private Integer doctorsType;

    /**
     * 从业医生的开始时间
     */
    private Date doctorsTimeWork;

    /**
     * 钱包提现密码
     */
    private String doctorsWalletPassword;

    /**
     * 微信小程序 openid
     */
    private String wxOpenid;

    /**
     * 微信公众号 openid
     */
    private String wxOaOpenid;

    /**
     * 微信 unionid
     */
    private String wxUnionid;

    /**
     * 医生标签
     */
    private String doctorsTag;

    private Date createTime;

    private Date updateTime;

    /**
     * 医生审核时间
     */
    private String doctorsVerifyTime;

    @TableLogic
    private Integer isDel;

    private String remark;

    @TableField("team_id")
    private Integer teamId;

    public DtrdEntRdDoctor() {
    }

    public DtrdEntRdDoctor(String mobile, String name, Integer doctorType) {
        this.doctorsMobile = mobile;
        this.doctorsName = name;
        this.doctorsType = doctorType;
    }

    public DtrdEntRdDoctor init() {
        isDel = 0;
        createTime = new Date();
        doctorsIsverify= DoctorVerifyState.TO_VERIFY.getState();
        doctorsStatus=0;
        return this;
    }

    public DtrdEntRdDoctor parseFromDTO(DoctorInfo dto) {
        // 从业医生起始时间
        doctorsTimeWork = dto.getDoctorsTimeWork();
        dataId = dto.getDataId();
        doctorsMobile = dto.getDoctorsMobile();
        doctorsPassword = dto.getDoctorsPassword();
        doctorsName = dto.getDoctorsName();
        doctorsBirthday = dto.getDoctorsBirthday();
        doctorsSex = dto.getDoctorsSex();
        doctorsIdCard = dto.getDoctorsIdCard();
        doctorsProvinceId = dto.getDoctorsProvinceId();
        doctorsCityId = dto.getDoctorsCityId();
        doctorsDistrictId = dto.getDoctorsDistrictId();
        doctorsImg = dto.getDoctorsImg();
        doctorsHospitalId = dto.getDoctorsHospitalId();
        doctorsHospital = dto.getDoctorsHospital();
        doctorsDepartment = dto.getDoctorsDepartment();
        doctorsLevel = dto.getDoctorsLevel();
        doctorsSpecialSkill = dto.getDoctorsSpecialSkill();
        doctorsWorkExperience = dto.getDoctorsWorkExperience();
        doctorsType = dto.getDoctorsType();
        doctorsCertificate = dto.getDoctorsCertificate();
        doctorsWorkPermits = dto.getDoctorsWorkPermits();
        doctorsWorkCard = dto.getDoctorsWorkCard();
        doctorsProfessionImg = dto.getDoctorsProfessionImg();
        doctorsTag = dto.getDoctorsTag();
        return this;
    }

    public DtrdEntRdDoctor parseFromDTO(UpdateTeamDoctorRequest dto) {
        doctorsName = dto.getDoctorName();
        doctorsMobile = dto.getDoctorPhone();
        doctorsType = dto.getDoctorType();
        return this;
    }

//    public DtrdEntRdDoctor parseFromDTO(DoctorTotalInfo dto) {
//        dataId = dto.getDataId();
//        doctorsMobile = dto.getDoctorsMobile();
//        doctorsName = dto.getDoctorsName();
//        doctorsBirthday = dto.getDoctorsBirthday();
//        doctorsSex = dto.getDoctorsSex();
//        doctorsIdCard = dto.getDoctorsIdCard();
//        doctorsProvinceId = dto.getDoctorsProvinceId();
//        doctorsCityId = dto.getDoctorsCityId();
//        doctorsDistrictId = dto.getDoctorsDistrictId();
//        doctorsImg = dto.getDoctorsImg();
//        doctorsHospitalId = dto.getDoctorsHospitalId();
//        doctorsDepartmentId = dto.getDoctorsDepartmentId();
//        doctorsLevelId = dto.getDoctorsLevelId();
//        doctorsCertificate = dto.getDoctorsCertificate();
//        doctorsWorkPermits = dto.getDoctorsWorkPermits();
//        doctorsDeptTel = dto.getDoctorsDeptTel();
//        doctorsSpecialSkill = dto.getDoctorsSpecialSkill();
//        doctorsWorkExperience = dto.getDoctorsWorkExperience();
//        doctorsRecommendId = dto.getDoctorsRecommendId();
//        doctorsWalletPassword=dto.getDoctorsWalletPassword();
//        doctorsIsdoctor = dto.getDoctorsIsdoctor();
//        doctorsIsverify = dto.getDoctorsIsverify();
//        doctorsStatus = dto.getDoctorsStatus();
//        doctorsIsShow = dto.getDoctorsIsShow();
//        doctorsRecommended = dto.getDoctorsRecommended();
//        doctorsIsCustom = dto.getDoctorsIsCustom();
//        doctorsInvitationCode = dto.getDoctorsInvitationCode();
//        doctorsLiveness = dto.getDoctorsLiveness();
//        doctorsScore = dto.getDoctorsScore();
//        doctorsTimeWork = dto.getDoctorsTimeWork();
//        doctorsIsFamous = dto.getDoctorsIsFamous();
//        doctorsSourceType = dto.getDoctorsSourceType();
//        doctorsIsInquiry = dto.getDoctorsIsInquiry();
//        doctorsType = dto.getDoctorsType();
//        doctorsTag = dto.getDoctorsTag();
//        return this;
//    }


    public DtrdEntRdDoctor parseFromDTO(WechatOfficialAccountUserInfo userInfo) {
        doctorsName = userInfo.getNickname();
        wxUnionid = userInfo.getUnionid();
        wxOaOpenid = userInfo.getOpenid();
        doctorsSex = userInfo.getSex();
        doctorsImg = userInfo.getHeadimgurl();
        return null;
    }
}
